#pragma once

#include "PlayFabBaseModel.h"

namespace PlayFab
{
    enum PlayFabErrorCode
    {
        PlayFabErrorHostnameNotFound = 1,
        PlayFabErrorConnectionTimeout,
        PlayFabErrorConnectionRefused,
        PlayFabErrorSocketError,
<% for (errIdx in apis[0].errors) { var apiErr = apis[0].errors[errIdx];
%>        PlayFabError<%- apiErr.name %> = <%- apiErr.id %>,
<% }
%>    };

    /// <summary>
    /// The wrapper around all PlayFab responses, and all fields needed in the case of an error
    /// </summary>
    struct PlayFabError : public PlayFabBaseModel
    {
        // Serialized fields
        int HttpCode;
        std::string HttpStatus;
        PlayFabErrorCode ErrorCode;
        std::string ErrorName;
        std::string ErrorMessage;
        web::json::value ErrorDetails;
        web::json::value Data;
        // Non-serialized fields
        std::string UrlPath;
        web::json::value Request;

        void FromJson(web::json::value& input) override;
        web::json::value ToJson() const override;

        std::string GenerateErrorReport() const;
    };

    typedef std::function<void(const PlayFabError& error, void* customData)> ErrorCallback;
}
